package cn.gjxblog.core.social.qq.provider;

import cn.gjxblog.core.social.qq.connect.QQAuth2Template;
import cn.gjxblog.core.social.qq.provider.api.QQ;
import cn.gjxblog.core.social.qq.provider.api.QQImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;
import org.springframework.social.oauth2.OAuth2Template;

/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2019/1/17 16:38
 */
public class QQProvider extends AbstractOAuth2ServiceProvider<QQ> {

    private String appid;

    private static final String URL_AUTHORIZE = "https://graph.qq.com/oauth2.0/authorize";//step.1

    private static final String URL_ACCESS_TOKEN = "https://graph.qq.com/oauth2.0/token";//step.4

    public QQProvider(String appId, String appSecret) {
        super(new QQAuth2Template(appId, appSecret, URL_AUTHORIZE, URL_ACCESS_TOKEN));
        this.appid=appId;
    }

    @Override
    public QQ getApi(String accessToken) {
        return new QQImpl(accessToken,appid);
    }
}
